Compute AND, OR, XOR, NOT and shifts with the binary result shown visually.
See AND, OR, XOR, NOT and shift operations in binary
Computes AND, OR and XOR of two integers, NOT of one, and left and right shifts, showing inputs and result side by side in binary, decimal and hexadecimal. For bit masks and flags, permission bits, checking programming homework, or subnet arithmetic.
It uses JavaScript's 32-bit integer operators directly. AND (&) gives 1 where both bits are 1, OR (|) where either is 1, XOR (^) where they differ, and NOT (~) flips every bit. Left shift (<<) multiplies by 2ⁿ; right shift (>>) divides by 2ⁿ, keeping the integer part. The binary display width follows the largest absolute value among A, B and the result, starting at 8 bits and growing in steps of 4 up to 32. It opens with A = 12 and B = 10, so 1100 AND 1010 = 1000, which is 8 in decimal and 0x8 in hex. With the same values OR gives 14 (0xE) and XOR gives 6 (0x6).
Flipping every bit of a 32-bit integer gives −(x + 1) under two's complement. To see it as 8 bits, AND the result with 255: 250.
It is an arithmetic shift (>>) that keeps the sign bit, so −8 >> 1 = −4. The unsigned shift (>>>) is not offered here.
No. JavaScript bitwise operators truncate to 32 bits, so values above 2,147,483,647 give wrong results.
The inputs accept decimal only. Convert 0xFF to 255 or 1010₂ to 10 first. Any fractional part is dropped, and the result is shown in binary, decimal and hex.
Posts · 0
No posts yet.